import request from "@/utils/request.js";
import { useTokenStore} from "@/stores/token.js";
//文章分类查询接口
export const articleCategoryListService = () => {
    //const tokenStore = useTokenStore() // 引入token
    // tokenStore.token
    //在Pina中定义的数据无需.value
    //return request.get('/category',{headers:{Authorization:tokenStore.token}});
    return request.get('/category/list');
}
//查询通过的分类
export const articleCategoryAllowListService = () => {
    return request.get('/category/allowList');
}
//查询驳回的分类
export const articleCategoryDisallowListService = () => {
    return request.get('/category/disallowList');
}
//查询待审核的分类
export const articleCategoryInspectListService = () => {
    return request.get('/category/inspectList');
}

//添加文章分类
export const articleCategoryAddService = (categoryData) => {
    return request.post('/category',categoryData);
}

//编辑文章分类
export const articleCategoryUpdateService = (categoryData) => {
    return request.put('/category',categoryData);
}

//删除文章分类
export const articleCategoryDeleteService = (id) => {
    return request.delete('/category?id='+id)
}
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
//文章列表查询接口
export const articleListService = (params) => {
    return request.get('/article/all',{params:params});
}//已通过
export const articleListInspectService = (params) => {
    return request.get('/article/all-inspect',{params:params});
}//待审核
export const articleListDisallowService = (params) => {
    return request.get('/article/all-disallow',{params:params});
}//已驳回

//添加文章
export const articleAddService = (articleData) => {
    return request.post('/article',articleData);
}

//修改文章
export const articleUpdateService = (articleData) => {
    return request.put('/article',articleData);
}

//删除已通过文章
export const articleDeleteService = (id) => {
    return request.delete('/article?id='+id)
}
//删除待审核文章
export const articleDeleteInspectService = (id) => {
    return request.delete('/article/inspect?id='+id)
}
//删除已驳回文章
export const articleDeleteDisallowService = (id) => {
    return request.delete('/article/disallow?id='+id)
}
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
//待审核->已通过
export const articleAllowService = (articleData) => {
    return request.put('/article/allow',articleData)
}
//待审核->已拒绝
export const articleDisallowService = (articleData) => {
    return request.put('/article/disallow',articleData)
}
//已通过->已拒绝
export const articleAllowToDisallowService = (articleData) => {
    return request.put('/article/allow-disallow',articleData)
}
//已拒绝->已通过
export const articleDisallowToAllowService = (articleData) => {
    return request.put('/article/disallow-allow',articleData)
}